#define _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char* longestCommonPrefix(char** strs, int strsSize)
{
    int count = 0;
    int i = 0;
    int j = 0;
    int min = strlen(*strs);
    for (i = 1; i < strsSize; i++)
    {
        if (strlen(strs[i]) < min)
        {
            min = strlen(strs[i]);
        }
    }
    for (i = 0; i < min; i++)
    {
        for (j = 0; j < strsSize - 1; j++)
        {
            if (strs[j][i] != strs[j + 1][i])
            {
                break;
            }
        }
        if (j == strsSize - 1)
        {
            count++;
        }
        else
        {
            break;
        }
    }
    char* ret = calloc(count + 1, sizeof(char));
    for (i = 0; i < count; i++)
    {
        ret[i] = strs[0][i];
    }
    return ret;
}

int main()
{
    char* strs[3] = { "flower", "flow", "flight" };
    int sz = 3;
    printf("%s", longestCommonPrefix(strs, sz));
    return 0;
}